package com.feng.d18Segregation;

/**
 * @author LiYilin on 2020/4/13
 */
public class TestMain {

    /**
     * 应该使用ConfigSource的实现类才对,这里不是演示的重点,故注释一下
     * ConfigSource configSource = new ZookeeperConfigSource();
     */
    private static ConfigSource zookeeperConfigSource = new ConfigSource();

    public static void main(String[] args) {
        RedisConfig redisConfig = new RedisConfig(zookeeperConfigSource);
        KafkaConfig kafkaConfig = new KafkaConfig(zookeeperConfigSource);
        ScheduledUpdater redisScheduledUpdater = new ScheduledUpdater(10, 10, redisConfig);
        redisScheduledUpdater.execute();
        ScheduledUpdater kafkaScheduledUpdater = new ScheduledUpdater(10, 10, kafkaConfig);
        kafkaScheduledUpdater.execute();

        //需求2
        MysqlConfig mysqlConfig = new MysqlConfig(zookeeperConfigSource);
        SimpleHttpServer simpleHttpServer = new SimpleHttpServer("127.0.0.1", 2389);
        simpleHttpServer.addViewers("/config", redisConfig);
        simpleHttpServer.addViewers("/config", mysqlConfig);
        simpleHttpServer.run();
    }
}
